package cn.nwpu.eckel.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.nwpu.eckel.Dao.ForecastDao;
import cn.nwpu.eckel.Dao.OrderDao;
import cn.nwpu.eckel.Dao.PlanDao;
import cn.nwpu.eckel.Dao.ScheduleReceiptDao;

/**
 * Servlet implementation class Rolling
 */
@WebServlet("/Rolling")
public class Rolling extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Rolling() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String mpsId=request.getParameter("mpsId");
		int mpsNo=Integer.parseInt(mpsId);
		ForecastDao.roll(mpsNo);
		OrderDao.roll(mpsNo);
		ScheduleReceiptDao.roll(mpsNo);
		PlanDao.roll(mpsNo);
		String rePath="index.jsp?mpsId="+mpsNo+"&source=mps";
		response.sendRedirect(rePath);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
